package sample

import (
	"gorm.io/gorm"
	"organoid_public/domain/sample/model"
	"organoid_public/domain/sample/repository"
	"organoid_public/infrastructure/db"
)

type UserRepository struct {
	db *gorm.DB
}

func NewUserRepository(db db.DefaultDb) repository.UserRepo {
	return &UserRepository{db: db}
}

func (u *UserRepository) GetUsersByUserName(username string) (*model.User, error) {
	var user model.User
	err := u.db.Debug().Model(&model.User{}).Where("name = ?", username).Find(&user).Error
	return &user, err
}
